package com.sakura.service;

import com.sakura.annotation.DataSourceTypeAnno;
import com.sakura.common.DataSourceEnum;
import com.sakura.dao.ShopDao;
import com.sakura.entity.Shop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by apple on 2018/12/25.
 */
@Service("shopService")
public class ShopService {
    @Autowired
    private ShopDao dao;

    public Shop getShop(int id) {
        return dao.getShop(id);
    }

//    public Shop getMasterShopByHandle(int id) {
//        return dao.getMasterShopByHandle(id);
//    }
//
//    public Shop getSlaverShopByHandle(int id) {
//        return dao.getSlaverShopByHandle(id);
//    }
//
    @DataSourceTypeAnno(DataSourceEnum.master)
    public Shop getMasterShopByAnnotation(int id) {
        return dao.getShop(id);
    }
//
    @DataSourceTypeAnno(DataSourceEnum.slaver)
    public Shop getSlaverShopByAnnotation(int id) {
        return dao.getShop(id);
    }

    @DataSourceTypeAnno(DataSourceEnum.master)
    //@Transactional
    public String updateShopById(String shopName, int id) throws ClassNotFoundException {
        dao.updateShopById(shopName, id);
        throw new ClassNotFoundException();
    }
}
